package com.lmx.repoDomain.repository;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import com.lmx.common.context.ActionContextHolder;
import com.lmx.repoDomain.tmodel.TokenInfo;

import io.katharsis.repository.annotations.JsonApiResourceRepository;
import io.katharsis.repository.annotations.JsonApiSave;

/**
 *
 * @author ytche
 * @date 2017年8月30日
 *
 */
@JsonApiResourceRepository(value = TokenInfo.class)
@Component
public class TokenInfoRepository extends BaseRepository<TokenInfo> {

	@SuppressWarnings("unchecked")
	@Override
	@JsonApiSave
	public TokenInfo save(TokenInfo entity) {
		if (StringUtils.isNotBlank(entity.getToken())) {
			ActionContextHolder.getEvaHolder().remove(entity.getToken());
		}
		return entity;
	}
}
